package com.heima.demo;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class Demo1 {
    public static void main(String[] args) throws Exception {
        InetAddress address =InetAddress.getByName("FanJinSong");
        String hostName = address.getHostName();
        System.out.println("主机名为:"+hostName);
        String hostAddress = address.getHostAddress();
        System.out.println("ip地址为:"+hostAddress);
    }
}
